﻿using Andy.Web.NguoiDungServiceReference;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Andy.Web.admin
{
    public partial class ht_doimatkhau : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btLuu_Click(object sender, EventArgs e)
        {
            var user = Session["nsd"] as NguoiDung;
            if (user == null) Response.Redirect("~/admin/Default.aspx");
            else
            {
                using (var userSrv = new NguoiDungServiceClient())
                {
                    var result = userSrv.DoiMatKhau(user.Id, txtMatKhauCu.Text, txtMatKhauMoi.Text);
                    if (result != null)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('"+result+"');", true);
                    }
                    else {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('Đổi mật khẩu thất bại. Yêu cầu kiểm tra lại !');", true);
                    }
                    txtMatKhauCu.Text = "";
                    txtMatKhauMoi.Text = "";
                    txtMatKhauMoi2.Text = "";
                }
            }
        }
    }
}